//
//  RootTabBarController.m
//  SchoolTimetable
//
//  Created by 梦里都是梦 on 16/1/6.
//  Copyright © 2016年 Yuanlinqian. All rights reserved.
//

#import "RootTabBarController.h"
#import "HomePageViewController.h"
#import "SyllabusPageViewController.h"
#import "PersonPageViewController.h"

//#import "ViewController.h"

#define BUTTON_TAG 100
@interface RootTabBarController ()


@end

@implementation RootTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self addViewControlers];
    [self customNewTabBar];
}
-(void)awakeFromNib
{
    [self addViewControlers];

}
- (void)addViewControlers
{
    UIStoryboard * storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    
    UINavigationController * homePageNavi = [[UINavigationController alloc]initWithRootViewController:[[HomePageViewController alloc]init]];
    [self addNaviBackgroundColorWiht:homePageNavi];
    SyllabusPageViewController * syllVc = [storyBoard instantiateViewControllerWithIdentifier:@"SyllabusPageViewController"];
    UINavigationController * syllabusNavi = [[UINavigationController alloc]initWithRootViewController:syllVc];
    [self addNaviBackgroundColorWiht:syllabusNavi];
    
    PersonPageViewController * personVc = [storyBoard instantiateViewControllerWithIdentifier:@"PersonPageViewController"];
    UINavigationController * personNavi = [[UINavigationController alloc]initWithRootViewController:personVc];
    [self addNaviBackgroundColorWiht:personNavi];
    NSArray * tabBarArray = [NSArray arrayWithObjects:homePageNavi,syllabusNavi,personNavi, nil];
    self.viewControllers = tabBarArray;
}
-(void)addNaviBackgroundColorWiht:(UINavigationController *)navi
{
    UINavigationBar * naviBar = navi.navigationBar;
    naviBar.barTintColor = [UIColor colorWithRed:233/255.f green:215/255.f blue:186/255.f alpha:1];
}
-(void)customNewTabBar
{
            // 先把自带的UITabBar隐藏
        self.tabBar.hidden = YES;
            // 获取屏幕的尺寸
        CGSize screenSize = [UIScreen mainScreen].bounds.size;
            // 定制UITabBar
        self.ownTabBar = [[TabBarView alloc]initWithFrame:CGRectMake(0, screenSize.height - 64, screenSize.width, 64)];
            [self.view addSubview:_ownTabBar];
        __weak typeof(self) weakSelf = self;
        self.ownTabBar.passIndex = ^(NSInteger index) {
       weakSelf.selectedIndex = index;
    };

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
